Computer simulation environments simulate the operation of dynamic systems. The simulators represent the various components of the systems being simulated with simulation elements. The simulation elements may be graphical or text-based and may represent both functional and non-functional components. Frequently, the component being simulated includes foreign code segments which are written in a non-native language (i.e.: not the language of the simulator). In such a case, an interface is created in the simulation environment to a foreign compiler or foreign simulator capable of executing the foreign code. The use of an interface to the foreign environment that allows the simulation of the foreign code is referred to as co-simulation.
Co-simulation offers a user the ability to simulate program code written in languages other than that which the simulation environment natively supports. This includes the simulation of non-native architecture-specific machine codes from within the host simulation environment. For a simulation environment such as Simulink® from the MathWorks, Inc. of Natick, Mass., a special purpose block for use with Simulink may be added to a block diagram that allows simulation of external codes. For a simulation environment such as MATLAB from the MathWorks, Inc., co-simulation may require a function or object that is utilized within a user's M code or directly from the command prompt, thereby allowing simulation of external code.
Unfortunately, simulation using conventional methods of co-simulation does not facilitate programmatic code generation following the simulation. In particular, conventional methods of programmatic code generation based on the results of the simulation of a system are unable to programmatically generate code for the foreign code associated with the co-simulation element. The foreign code associated with the co-simulation element must often be hand coded into the generated code, a process that is time consuming, inefficient, and prohibits the block diagram from providing a complete and turn-key solution for automatic code generation.